#region License
// Copyright 2007-2008 Rory Plaire (codekaizen@gmail.com)
/*
 * This license governs use of the accompanying software. If you use the software, you
 * accept this license. If you do not accept the license, do not use the software.
 * 
 * 1. Definitions
 * The terms "reproduce," "reproduction," "derivative works," and "distribution" have the
 * same meaning here as under U.S. copyright law.
 * A "contribution" is the original software, or any additions or changes to the software.
 * A "contributor" is any person that distributes its contribution under this license.
 * "Licensed patents" are a contributor's patent claims that read directly on its contribution.
 * 
 * 2. Grant of Rights
 * (A) Copyright Grant- Subject to the terms of this license, including the license conditions 
 *     and limitations in section 3, each contributor grants you a non-exclusive, worldwide, 
 *     royalty-free copyright license to reproduce its contribution, prepare derivative works 
 *     of its contribution, and distribute its contribution or any derivative works that you create.
 * (B) Patent Grant- Subject to the terms of this license, including the license conditions and 
 *     limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free 
 *     license under its licensed patents to make, have made, use, sell, offer for sale, import, 
 *     and/or otherwise dispose of its contribution in the software or derivative works of the 
 *     contribution in the software.
 * 
 * 3. Conditions and Limitations
 * (A) No Trademark License- This license does not grant you rights to use any contributors' 
 *     name, logo, or trademarks.
 * (B) If you bring a patent claim against any contributor over patents that you claim are 
 *     infringed by the software, your patent license from such contributor to the software 
 *     ends automatically.
 * (C) If you distribute any portion of the software, you must retain all copyright, patent, 
 *     trademark, and attribution notices that are present in the software.
 * (D) If you distribute any portion of the software in source code form, you may do so only under 
 *     this license by including a complete copy of this license with your distribution. If you 
 *     distribute any portion of the software in compiled or object code form, you may only do so 
 *     under a license that complies with this license.
 * (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no 
 *     express warranties, guarantees or conditions. You may have additional consumer rights under 
 *     your local laws which this license cannot change. To the extent permitted under your local laws, 
 *     the contributors exclude the implied warranties of merchantability, fitness for a particular 
 *     purpose and non-infringement.
 * 
 */
#endregion

using System;
using NPack.Interfaces;

namespace NPack
{
    /// <summary>
    /// A matrix component value modeled by a single-precision floating point.
    /// </summary>
    /// <remarks>
    /// Use this structure as the type parameter for an <see cref="IMatrix{T}"/> or 
    /// <see cref="IVector{T}"/> when you want
    /// a matrix of single values, since it implements <see cref="IComputable{T}"/>, which 
    /// allows numerical operations on value types.
    /// </remarks>
    [Serializable]
    public struct SingleComponent : IEquatable<SingleComponent>,
                                    IComparable<SingleComponent>, 
                                    IComputable<Double, SingleComponent>,
                                    IEquatable<Single>, 
                                    IComparable<Single>, 
                                    IComputable<Single>,
                                    IConvertible, 
                                    IFormattable
    {
        private Single _value;

        /// <summary>
        /// Creates a new SingleComponent initialized to the given 
        /// <paramref name="value"/>.
        /// </summary>
        /// <param name="value">
        /// The value to set this SingleComponent to.
        /// </param>
        public SingleComponent(Single value)
        {
            _value = value;
        }

        public SingleComponent Add(Double b)
        {
            return (Single)(_value + b);
        }

        public SingleComponent Subtract(Double b)
        {
            return (Single)(_value - b);
        }

        public SingleComponent Multiply(Double b)
        {
            return (Single)(_value * b);
        }

        public SingleComponent Divide(Double b)
        {
            return (Single)(_value / b);
        }

        /// <summary>
        /// Returns String representation of this value.
        /// </summary>
        /// <returns>A formatted String displaying this value.</returns>
        public override String ToString()
        {
            return _value.ToString();
        }

        /// <summary>
        /// Generates a hash code for the SingleComponent value.
        /// </summary>
        /// <returns>A value to represent this value in a hash table.</returns>
        public override Int32 GetHashCode()
        {
            return _value.GetHashCode();
        }

        /// <summary>
        /// Implicitly converts a Single value to a SingleComponent.
        /// </summary>
        /// <param name="value">Value to convert.</param>
        /// <returns>
        /// A SingleComponent set to <paramref name="value"/>.
        /// </returns>
        public static implicit operator SingleComponent(Single value)
        {
            return new SingleComponent(value);
        }

        /// <summary>
        /// Explicitly converts a SingleComponent to a Single.
        /// </summary>
        /// <param name="component">SingleComponent to convert.</param>
        /// <returns>
        /// Value of type Single with the same value as the SingleComponent.
        /// </returns>
        public static explicit operator Single(SingleComponent component)
        {
            return component._value;
        }

        /// <summary>
        /// Adds a SingleComponent and a Single.
        /// </summary>
        /// <param name="lhs">Left hand of the addition operation.</param>
        /// <param name="rhs">Right hand of the addition operation.</param>
        /// <returns>
        /// The sum of <paramref name="lhs"/> and <paramref name="rhs"/>.
        /// </returns>
        public static Single operator +(SingleComponent lhs, Single rhs)
        {
            return lhs._value + rhs;
        }

        /// <summary>
        /// Subtracts a Single from a SingleComponent.
        /// </summary>
        /// <param name="lhs">Left hand of the subtraction operation.</param>
        /// <param name="rhs">Right hand of the subtraction operation.</param>
        /// <returns>
        /// The difference of <paramref name="lhs"/> and <paramref name="rhs"/>.
        /// </returns>
        public static Single operator -(SingleComponent lhs, Single rhs)
        {
            return lhs._value - rhs;
        }

        #region IEquatable<SingleComponent> Members

        /// <summary>
        /// Evaluates equality of two SingleComponent instances.
        /// </summary>
        /// <param name="other">The SingleComponent to compare to.</param>
        /// <returns>
        /// True if the two SingleComponent instances are equal; false otherwise.
        /// </returns>
        public Boolean Equals(SingleComponent other)
        {
            return _value == other._value;
        }

        #endregion

        #region IComparable<SingleComponent> Members

        /// <summary>
        /// Compares two SingleComponent instances.
        /// </summary>
        /// <param name="other">The SingleComponent to compare to.</param>
        /// <returns>
        /// 0 if they are equal,
        /// 1 if the called-on instance is greater, 
        /// -1 if <paramref name="other"/> is greater.
        /// </returns>
        public Int32 CompareTo(SingleComponent other)
        {
            return _value.CompareTo(other._value);
        }

        #endregion

        #region IAddable<SingleComponent> Members

        /// <summary>
        /// Adds two SingleComponent values.
        /// </summary>
        /// <param name="a">The other addend.</param>
        /// <returns>
        /// The sum of this SingleComponent and <paramref name="a"/>.
        /// </returns>
        public SingleComponent Add(SingleComponent a)
        {
            return new SingleComponent(_value + a._value);
        }

        #endregion

        #region ISubtractable<SingleComponent> Members

        /// <summary>
        /// Subtracts two SingleComponent values.
        /// </summary>
        /// <param name="a">The subtrahend.</param>
        /// <returns>
        /// The difference of this SingleComponent (minuend) and 
        /// <paramref name="a"/>.
        /// </returns>
        public SingleComponent Subtract(SingleComponent a)
        {
            return new SingleComponent(_value - a._value);
        }

        #endregion

        #region IHasZero<SingleComponent> Members

        /// <summary>
        /// Returns the zero value for a SingleComponent. Equal to 0F.
        /// </summary>
        public SingleComponent Zero
        {
            get { return new SingleComponent(0F); }
        }

        #endregion

        #region INegatable<SingleComponent> Members

        /// <summary>
        /// Returns the negation of the SingleComponent value. Also the
        /// additive inverse.
        /// </summary>
        /// <remarks>
        /// The value returns solves the following equation:
        /// <code>
        /// SingleComponent a = 5, b = a.Negative();
        /// 
        /// Assert.IsTrue(a.Add(b).Equals(0));
        /// </code>
        /// </remarks>
        /// <returns>The negated SingleComponent.</returns>
        public SingleComponent Negative()
        {
            return new SingleComponent(-_value);
        }

        #endregion

        #region IMultipliable<SingleComponent> Members

        /// <summary>
        /// Multiplies two SingleComponents and returns the product.
        /// </summary>
        /// <param name="a">The multiplier.</param>
        /// <returns>
        /// The product of the SingleComponent instance and 
        /// <paramref name="a"/>.
        /// </returns>
        public SingleComponent Multiply(SingleComponent a)
        {
            return new SingleComponent(_value*a._value);
        }

        #endregion

        #region IDivisible<SingleComponent> Members

        /// <summary>
        /// Divides two SingleComponent instances and returns the quotient.
        /// </summary>
        /// <param name="a">The divisor.</param>
        /// <returns>
        /// The quotient of dividing the SingleComponent instance
        /// (the dividend) and <paramref name="a"/>.
        /// </returns>
        public SingleComponent Divide(SingleComponent a)
        {
            return new SingleComponent(_value/a._value);
        }

        #endregion

        #region IHasOne<SingleComponent> Members

        /// <summary>
        /// Returns the multiplicative identity.
        /// </summary>
        public SingleComponent One
        {
            get { return new SingleComponent(1); }
        }

        #endregion

        #region IEquatable<Single> Members

        /// <summary>
        /// Evaluates equality of a SingleComponent instance and a Single value.
        /// </summary>
        /// <param name="other">The Single value to compare to.</param>
        /// <returns>
        /// True if the two SingleComponent instances are equal; false otherwise.
        /// </returns>
        public Boolean Equals(Single other)
        {
            return _value == other;
        }

        #endregion

        #region IComparable<Single> Members

        /// <summary>
        /// Compares a SingleComponent instance and a Single value.
        /// </summary>
        /// <param name="other">The Single value to compare to.</param>
        /// <returns>
        /// 0 if they are equal,
        /// 1 if the SingleComponent instance is greater, 
        /// -1 if <paramref name="other"/> is greater.
        /// </returns>
        public Int32 CompareTo(Single other)
        {
            return _value.CompareTo(other);
        }

        #endregion

        #region IAddable<Single> Members

        /// <summary>
        /// Adds a SingleComponent value and a Single.
        /// </summary>
        /// <param name="a">The other addend.</param>
        /// <returns>
        /// The sum of this SingleComponent and <paramref name="a"/>.
        /// </returns>
        public Single Add(Single a)
        {
            return _value + a;
        }

        #endregion

        #region ISubtractable<Single> Members

        /// <summary>
        /// Subtracts a Single value from the SingleComponent value.
        /// </summary>
        /// <param name="a">The subtrahend.</param>
        /// <returns>
        /// The difference of this SingleComponent (minuend) and 
        /// <paramref name="a"/>.
        /// </returns>
        public Single Subtract(Single a)
        {
            return _value - a;
        }

        #endregion

        #region IHasZero<Single> Members

        /// <summary>
        /// Gets the additive identity as a Single: 0F.
        /// </summary>
        Single IHasZero<Single>.Zero
        {
            get { return 0.0F; }
        }

        #endregion

        #region INegatable<Single> Members

        /// <summary>
        /// Returns the negation of the SingleComponent value as a Single. Also the
        /// additive inverse.
        /// </summary>
        /// <remarks>
        /// The value returns solves the following equation:
        /// <code>
        /// SingleComponent a = 5, b = a.Negative();
        /// 
        /// Assert.IsTrue(a.Add(b).Equals(0));
        /// </code>
        /// </remarks>
        /// <returns>The negated SingleComponent as a Single.</returns>
        Single INegatable<Single>.Negative()
        {
            return -_value;
        }

        #endregion

        #region IMultipliable<Single> Members

        /// <summary>
        /// Multiplies the SingleComponent with Single and returns the product.
        /// </summary>
        /// <param name="a">The multiplier.</param>
        /// <returns>
        /// The product of the SingleComponent instance and 
        /// <paramref name="a"/>.
        /// </returns>
        public Single Multiply(Single a)
        {
            return _value*a;
        }

        #endregion

        #region IDivisible<Single> Members

        /// <summary>
        /// Divides the SingleComponent by a Single and returns the quotient.
        /// </summary>
        /// <param name="a">The divisor.</param>
        /// <returns>
        /// The quotient of dividing the SingleComponent instance
        /// (the dividend) and <paramref name="a"/>.
        /// </returns>
        public Single Divide(Single a)
        {
            return _value/a;
        }

        #endregion

        #region IHasOne<Single> Members

        /// <summary>
        /// Gets the multiplicative identity as a Single: 1F.
        /// </summary>
        Single IHasOne<Single>.One
        {
            get { return 1.0F; }
        }

        #endregion

        #region IBooleanComparable<SingleComponent> Members

        /// <summary>
        /// Evaluates if the SingleComponent instance is greater than 
        /// the given value.
        /// </summary>
        /// <param name="value">The value to compare to.</param>
        /// <returns>True if the SingleComponent instance is greater
        /// than <paramref name="value"/>; false otherwise.</returns>
        public Boolean GreaterThan(SingleComponent value)
        {
            return _value > value._value;
        }

        /// <summary>
        /// Evaluates if the SingleComponent instance is greater than 
        /// or equal to the given value.
        /// </summary>
        /// <param name="value">The value to compare to.</param>
        /// <returns>
        /// True if the SingleComponent instance is greater
        /// than or equal to <paramref name="value"/>; false otherwise.
        /// </returns>
        public Boolean GreaterThanOrEqualTo(SingleComponent value)
        {
            return _value >= value._value;
        }

        /// <summary>
        /// Evaluates if the SingleComponent instance is less than 
        /// the given value.
        /// </summary>
        /// <param name="value">The value to compare to.</param>
        /// <returns>True if the SingleComponent instance is less
        /// than <paramref name="value"/>; false otherwise.</returns>
        public Boolean LessThan(SingleComponent value)
        {
            return _value < value._value;
        }

        /// <summary>
        /// Evaluates if the SingleComponent instance is less than 
        /// or equal to the given value.
        /// </summary>
        /// <param name="value">The value to compare to.</param>
        /// <returns>
        /// True if the SingleComponent instance is less
        /// than or equal to <paramref name="value"/>; false otherwise.
        /// </returns>
        public Boolean LessThanOrEqualTo(SingleComponent value)
        {
            return _value <= value._value;
        }

        #endregion

        #region IBooleanComparable<Single> Members

        /// <summary>
        /// Evaluates if the SingleComponent instance is greater than 
        /// the given Single value.
        /// </summary>
        /// <param name="value">The value to compare to.</param>
        /// <returns>True if the SingleComponent instance is greater
        /// than <paramref name="value"/>; false otherwise.</returns>
        public Boolean GreaterThan(Single value)
        {
            return _value > value;
        }

        /// <summary>
        /// Evaluates if the SingleComponent instance is greater than 
        /// or equal to the given Single value.
        /// </summary>
        /// <param name="value">The value to compare to.</param>
        /// <returns>
        /// True if the SingleComponent instance is greater
        /// than or equal to <paramref name="value"/>; false otherwise.
        /// </returns>
        public Boolean GreaterThanOrEqualTo(Single value)
        {
            return _value >= value;
        }

        /// <summary>
        /// Evaluates if the SingleComponent instance is less than 
        /// the given Single value.
        /// </summary>
        /// <param name="value">The value to compare to.</param>
        /// <returns>True if the SingleComponent instance is less
        /// than <paramref name="value"/>; false otherwise.</returns>
        public Boolean LessThan(Single value)
        {
            return _value < value;
        }

        /// <summary>
        /// Evaluates if the SingleComponent instance is less than 
        /// or equal to the given Single value.
        /// </summary>
        /// <param name="value">The value to compare to.</param>
        /// <returns>
        /// True if the SingleComponent instance is less
        /// than or equal to <paramref name="value"/>; false otherwise.
        /// </returns>
        public Boolean LessThanOrEqualTo(Single value)
        {
            return _value <= value;
        }

        #endregion

        #region IExponential<SingleComponent> Members

        /// <summary>
        /// Raises the SingleComponent value to the given exponent.
        /// <paramref name="power"/>.
        /// </summary>
        /// <param name="power">
        /// The value of the exponent.
        /// </param>
        /// <returns>
        /// The value of the SingleComponent (the base) 
        /// raised to the given power.
        /// </returns>
        public SingleComponent Power(Double power)
        {
            return new SingleComponent((Single) Math.Pow(_value, power));
        }

        /// <summary>
        /// Computes the value of the square root of the SingleComponent.
        /// </summary>
        /// <returns>
        /// The value of the square root of the SingleComponent.
        /// </returns>
        public SingleComponent Sqrt()
        {
            return new SingleComponent((Single) Math.Sqrt(_value));
        }

        /// <summary>
        /// Computes the log of the SingleComponent in the
        /// <paramref name="newBase">given base</paramref>.
        /// </summary>
        /// <param name="newBase">The base to compute the log in.</param>
        /// <returns>
        /// The log of the SingleComponent in the new base given.
        /// </returns>
        public SingleComponent Log(Double newBase)
        {
            return new SingleComponent((Single) Math.Log(_value, newBase));
        }

        /// <summary>
        /// Computes the log of the SingleComponent in base e.
        /// </summary>
        /// <returns>The natural log of the SingleComponent.</returns>
        public SingleComponent Log()
        {
            return new SingleComponent((Single) Math.Log(_value));
        }

        /// <summary>
        /// Computes e to the power of the SingleComponent.
        /// </summary>
        /// <returns>
        /// The natural log base, e, raised to the power 
        /// of the value of the SingleComponent.
        /// </returns>
        public SingleComponent Exp()
        {
            return new SingleComponent((Single) Math.Exp(_value));
        }

        #endregion

        #region IExponential<Single> Members

        /// <summary>
        /// Raises the SingleComponent value to the given 
        /// exponent, returned as a Single.
        /// <paramref name="power"/>.
        /// </summary>
        /// <param name="power">
        /// The value of the exponent.
        /// </param>
        /// <returns>
        /// The value of the SingleComponent (the base) 
        /// raised to the given power.
        /// </returns>
        Single IExponential<Single>.Power(Double power)
        {
            return (Single) Math.Pow(_value, power);
        }

        /// <summary>
        /// Computes the value of the square root of the SingleComponent,
        /// returned as a Single.
        /// </summary>
        /// <returns>
        /// The value of the square root of the SingleComponent.
        /// </returns>
        Single IExponential<Single>.Sqrt()
        {
            return (Single) Math.Sqrt(_value);
        }

        /// <summary>
        /// Computes the log of the SingleComponent in the
        /// <paramref name="newBase">given base</paramref>, 
        /// returned as a Single.
        /// </summary>
        /// <param name="newBase">The base to compute the log in.</param>
        /// <returns>
        /// The log of the SingleComponent in the new base given.
        /// </returns>
        Single IExponential<Single>.Log(Double newBase)
        {
            return (Single) Math.Log(_value, newBase);
        }

        /// <summary>
        /// Computes the log of the SingleComponent in base e,
        /// returned as a Single.
        /// </summary>
        /// <returns>The natural log of the SingleComponent.</returns>
        Single IExponential<Single>.Log()
        {
            return (Single) Math.Log(_value);
        }

        /// <summary>
        /// Computes e to the power of the SingleComponent,
        /// returned as a Single.
        /// </summary>
        /// <returns>
        /// The natural log base, e, raised to the power 
        /// of the value of the SingleComponent.
        /// </returns>
        Single IExponential<Single>.Exp()
        {
            return (Single) Math.Exp(_value);
        }

        #endregion

        #region IComputable<SingleComponent> Members

        /// <summary>
        /// Computes the absolute value of the SingleComponent.
        /// </summary>
        /// <returns>
        /// The absolute value of the SingleComponent's value.
        /// </returns>
        public SingleComponent Abs()
        {
            return new SingleComponent(Math.Abs(_value));
        }

        /// <summary>
        /// Sets the value of the SingleComponent.
        /// </summary>
        /// <param name="value">
        /// The value to set the SingleComponent to, cast to a Single.
        /// </param>
        /// <returns>
        /// A SingleComponent with the given <paramref name="value"/>.
        /// </returns>
        public SingleComponent Set(Double value)
        {
            _value = (Single) value;
            return this;
        }

        #endregion

        #region IComputable<Single> Members

        /// <summary>
        /// Computes the absolute value of the SingleComponent,
        /// returned as a Single.
        /// </summary>
        /// <returns>
        /// The absolute value of the SingleComponent's value.
        /// </returns>
        Single IComputable<Single>.Abs()
        {
            return Math.Abs(_value);
        }

        /// <summary>
        /// Computes the absolute value of the SingleComponent,
        /// returned as a Single.
        /// </summary>
        /// <returns>
        /// The absolute value of the SingleComponent's value.
        /// </returns>
        Single IComputable<Single>.Set(Double value)
        {
            _value = (Single) value;
            return _value;
        }

        #endregion

        #region IConvertible Members

        /// <summary>
        /// Gets the TypeCode value for the SingleComponent.
        /// </summary>
        /// <returns><see cref="TypeCode.Single"/></returns>
        public TypeCode GetTypeCode()
        {
            return TypeCode.Single;
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="Boolean"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="Boolean"/>.</returns>
        public Boolean ToBoolean(IFormatProvider provider)
        {
            return Convert.ToBoolean(_value, provider);
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="Byte"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="Byte"/>.</returns>
        public Byte ToByte(IFormatProvider provider)
        {
            return Convert.ToByte(_value, provider);
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="Char"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="Char"/>.</returns>
        public Char ToChar(IFormatProvider provider)
        {
            return Convert.ToChar(_value, provider);
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="DateTime"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="DateTime"/>.</returns>
        public DateTime ToDateTime(IFormatProvider provider)
        {
            return Convert.ToDateTime(_value, provider);
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="Decimal"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="Decimal"/>.</returns>
        public Decimal ToDecimal(IFormatProvider provider)
        {
            return Convert.ToDecimal(_value, provider);
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="Double"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="Double"/>.</returns>
        public Double ToDouble(IFormatProvider provider)
        {
            return _value;
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="Int16"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="Int16"/>.</returns>
        public Int16 ToInt16(IFormatProvider provider)
        {
            return Convert.ToInt16(_value, provider);
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="Int32"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="Int32"/>.</returns>
        public Int32 ToInt32(IFormatProvider provider)
        {
            return Convert.ToInt32(_value, provider);
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="Int64"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="Int64"/>.</returns>
        public Int64 ToInt64(IFormatProvider provider)
        {
            return Convert.ToInt64(_value, provider);
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="SByte"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="SByte"/>.</returns>
        [CLSCompliant(false)]
        public SByte ToSByte(IFormatProvider provider)
        {
            return Convert.ToSByte(_value, provider);
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="Single"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="Single"/>.</returns>
        public Single ToSingle(IFormatProvider provider)
        {
            return _value;
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="String"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="String"/>.</returns>
        public String ToString(IFormatProvider provider)
        {
            return Convert.ToString(_value, provider);
        }

        /// <summary>
        /// Converts the SingleComponent to a value of the given type.
        /// </summary>
        /// <param name="conversionType">
        /// Type to convert to.
        /// </param>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>
        /// The SingleComponent as a value of <paramref name="conversionType"/>.
        /// </returns>
        public Object ToType(Type conversionType, IFormatProvider provider)
        {
            return Convert.ChangeType(_value, conversionType, provider);
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="UInt16"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="UInt16"/>.</returns>
        [CLSCompliant(false)]
        public UInt16 ToUInt16(IFormatProvider provider)
        {
            return Convert.ToUInt16(_value, provider);
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="UInt32"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="UInt32"/>.</returns>
        [CLSCompliant(false)]
        public UInt32 ToUInt32(IFormatProvider provider)
        {
            return Convert.ToUInt32(_value, provider);
        }

        /// <summary>
        /// Converts the SingleComponent to a <see cref="UInt64"/> value.
        /// </summary>
        /// <param name="provider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help convert the SingleComponent value.
        /// </param>
        /// <returns>The SingleComponent as a <see cref="UInt64"/>.</returns>
        [CLSCompliant(false)]
        public UInt64 ToUInt64(IFormatProvider provider)
        {
            return Convert.ToUInt64(_value, provider);
        }

        #endregion

        #region IFormattable Members

        /// <summary>
        /// Generates a String representation of the SingleComponent.
        /// </summary>
        /// <param name="format">The format String to use in formatting.</param>
        /// <param name="formatProvider">
        /// An <see cref="IFormatProvider"/> instance used to 
        /// help format the SingleComponent value.
        /// </param>
        /// <returns>
        /// A formatted String which represents the SingleComponent value.
        /// </returns>
        public String ToString(String format, IFormatProvider formatProvider)
        {
            return _value.ToString(format, formatProvider);
        }

        #endregion
    }
}